$(function(){
	$(".coll_body").eq(1).show();
	$(".coll_body").eq(1).children('a').eq(2).addClass("active");
	$(".Collapsing").eq(1).children('a').children('span').addClass("rotate");
	$(".Collapsing").eq(1).click(function(){
		$(".Collapsing").eq(1).toggleClass("active");
		$(this).children('.coll_body').children('a').eq(2).toggleClass("active");
	})
})
//	签约方式列表
	var pageSize = 15;
	var currentPage = 1; 
	ajaxTest(currentPage);
	
	function ajaxTest(currentPage) {
		$.ajax({
				type:"post",
				url:serverIP+"/user/signMethod/list",
				dataType:"json",
				xhrFields: {
	                withCredentials: true    // 设置sessionId相同
	            },
	            data: {page:currentPage},
				success:function (data) {
					if(data.code==0){
						let result=data.data.list.result;
						var strVar = "";
						result.map(function(u){
							if(u.status==01){
								status="启用"
							}else{
								status="停用"
							}
							var createTime=u.createTime.slice(0,10);
							if(u.finishDate){
								var finishTime=u.finishDate.slice(0,10);
							}else{
								var finishTime="";
							}
							if(u.payMethod==01){
								var payMethod="包年";
							}else if(u.payMethod==02){
								var payMethod="包月";
							}else if(u.payMethod==03){
								var payMethod="按打印纸张数";
							}else{
								var payMethod=u.payMethod;
							}
							
							strVar += "              <tr>\n";
						    strVar += "                <td>"+u.signMethodId+"<\/td>\n";
						    strVar += "                <td>"+u.name+"<\/td>\n";
						    strVar += "                <td>"+status+"<\/td>\n";
						    strVar += "                <td>"+createTime+"<\/td>\n";
						    strVar += "                <td>"+finishTime+"<\/td>\n";
						    strVar += "                <td>"+u.monoSinglePrice+"<\/td>\n";
						    strVar += "                <td>"+u.colorSinglePrice+"<\/td>\n";
						    strVar += "                <td>"+u.papeNum+"<\/td>\n";
						    strVar += "                <td>"+u.deposit+"<\/td>\n";
						    strVar += "                <td>"+payMethod+"<\/td>\n";
						    strVar += "                <td>"+u.other+"<\/td>\n";
						    strVar += "                <td class=\"noExl\">\n"; 
						    strVar += "                		<div>\n"; 
						    strVar += "                			<span class=\"btn edit\" value="+u.signMethodId+">\n"; 
						    strVar += "                				<i class=\"icon-edit\"></i>编辑\n"; 
						    strVar += "                			</span>\n"; 
						    strVar += "                			<span class=\"btn delete\" value="+u.signMethodId+">\n"; 
						    strVar += "                				<i class=\"icon-trash\"></i>删除\n"; 
						    strVar += "                			</span>\n";
						    strVar += "                		</div>\n";
						    strVar += "                <\/td>\n"; 
						    strVar += "              <\/tr>";
						})
						$('.print-tbody').html(strVar);
					//分页
						$("#page").paging({
							pageNo: data.data.list.curPage,
							totalPage: data.data.list.totalPage,
							totalSize: data.data.list.totalRow,
							callback: function(currentPage) {
								ajaxTest(currentPage); 
							}
						});
					}else{
						alert(data.msg);
						window.location.href="login.html";
					}/*if-End*/
				}
		})
	}
//监听浏览器窗口变化
window.onresize = function(){
	var bodyH=$("body").height();
	$(".leftbar").height(bodyH-45+"px");
	$(".content").height(bodyH-45+"px");
	$(".admin").height($(".content").height()-45+"px");
}
$('.add').click(function(){
	window.location.href="addsign.html";
})
$("body").on("click",".edit",function(){
	var sid=$(this).attr("value");
	window.location.href="editsign.html?sid="+sid;
})
$("body").on("click",".delete",function(){
	if(confirm("确定要删除本条信息么")){
		var sid=$(this).attr("value");
		$.ajax({  
	        type : "POST",  
	        url : serverIP+'/user/signMethod/del',  
	        data : {
	        	signMethodId:sid
	        },
	        xhrFields: {
	            withCredentials: true    // 设置sessionId相同
	        },
	        success : function(){  
	        	window.location.reload();
	        }  
	    });
	}
}); 